CJPEG

Section: User Commands (1)
Updated: 11 December 1991
Index Return to Main Contents
 

NAME

cjpeg - compress an image file to a JPEG file  

SYNOPSIS

cjpeg [ -Q quality ] [ -oTIad ] [ filename ]

 

DESCRIPTION

cjpeg compresses the named image file, or the standard input if no file is named, and produces a JPEG/JFIF file on the standard output. The currently supported image file formats are: PPM (PBMPLUS color format), PGM (PBMPLUS gray-scale format), GIF, Targa, and RLE (Utah Raster Toolkit format). (RLE is supported only if the URT library is available.)  

OPTIONS

-Q quality
Scale quantization tables to adjust image quality. Quality is 0 (worst) to 100 (best); default is 75. (See below for more info.)
-o
Perform optimization of entropy encoding parameters. Without this, default encoding parameters are used. -o usually makes the JPEG file a little smaller, but cjpeg runs much slower. Image quality and speed of decompression are unaffected by -o.
-T
Input file is Targa format. Targa files that contain an "identification" field will not be automatically recognized by cjpeg; for such files you must specify -T to force cjpeg to treat the input as Targa format.
-I
Generate noninterleaved JPEG file (not yet supported).
-a
Use arithmetic coding rather than Huffman coding (not currently supported for legal reasons).
-d
Enable debug printout. More -d's give more output. Also, version information is printed at startup.

The -Q switch lets you trade off compressed file size against quality of the reconstructed image: the higher the -Q setting, the larger the JPEG file, and the closer the output image will be to the original input. Normally you want to use the lowest -Q setting (smallest file) that decompresses into something visually indistinguishable from the original image. For this purpose the -Q setting should be between 50 and 95; the default of 75 is often about right. If you see defects at -Q 75, then go up 5 or 10 counts at a time until you are happy with the output image. (The optimal setting will vary from one image to another.)

-Q 100 will generate a quantization table of all 1's, eliminating loss in the quantization step (but there is still information loss in subsampling, as well as roundoff error). This setting is mainly of interest for experimental purposes. -Q values above about 95 are not recommended for normal use; the compressed file size goes up dramatically for hardly any gain in output image quality.

In the other direction, -Q values below 50 will produce very small files of low image quality. Settings around 5 to 10 might be useful in preparing an index of a large image library, for example. Try -Q 2 (or so) for some amusing Cubist effects. (Note: -Q values below about 25 generate 2-byte quantization tables, which are considered optional in the JPEG standard. cjpeg emits a warning message when you give such a -Q value, because some commercial JPEG programs may be unable to decode the resulting file.)  

EXAMPLES

This example compresses the PPM file foo.ppm with a quality factor of 60 and saves the output as foo.jpg:

cjpeg -Q 60 foo.ppm > foo.jpg
 

SEE ALSO

djpeg(1)
Wallace, Gregory K. "The JPEG Still Picture Compression Standard", Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.  

AUTHOR

Independent JPEG Group  

BUGS

Arithmetic coding and interleaved output not yet supported.

Not all variants of Targa file format are supported.

The -T switch is not a bug, it's a feature. (It would be a bug if the Targa format designers had not been clueless.)

Not as fast as we'd like.


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXAMPLES
SEE ALSO
AUTHOR
BUGS

This document was created by man2html, using the manual pages.
Time: 23:15:03 GMT, January 29, 2023